﻿Imports Utilidades
Imports Excepciones
Imports Negocio
Imports Servicios
Imports System.IO

Public Class frmABMIdioma

    Private _idioma As New Idioma()
    Private WithEvents m_CurrencyManager As CurrencyManager

    Protected Overrides Sub PreLoad()
        Me.Icon = Icon.FromHandle(Global.SIPRO.My.Resources.Resources.Language.GetHicon())
    End Sub

    Sub New()
        InitializeComponent()
    End Sub
    Sub New(idioma As Idioma)
        Me.New()
        _idioma = idioma
        btnGuardar.Tag = "Modificar"
    End Sub

    Private Sub frmNuevoIdioma_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtNombre.DataBindings.Add("Text", _idioma, "Nombre")
        txtRuta.DataBindings.Add("Text", _idioma, "Archivo")
    End Sub

    Private Sub OK_Click(sender As System.Object, e As System.EventArgs) Handles btnGuardar.Click
        If MyBase.ValidateForm() Then
            Try
                GesIdiomas.Guardar(_idioma)
                Me.Close()
                Me.DialogResult = Windows.Forms.DialogResult.OK
            Catch ex As Exception
                My.Application.HandlerException(New LanguageSaveException())
            End Try
        End If

    End Sub

    Private Sub Cancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancelar.Click
        Me.Close()
    End Sub

    Private Sub ButtonExt1_Click(sender As System.Object, e As System.EventArgs) Handles btnEditar.Click
        Dim frm As New frmEditIdioma(_idioma)
        frm.ShowDialog()
    End Sub

End Class